home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Demos / Codeworks 0.94b3 / Codeworks® WWW Demo Doc. / Scripting Manual.doc / Scripting Manual.doc.rsrc / TEXT_142.txt < prev    next >
Encoding:
Text File  |  1995-05-01  |  937 b   |  18 lines

  1. Writing Scripts - Returning Values
  2.  
  3.     Scripts in an object can return values just like the scripts you‚Äôve written in a workspace.  There is one difference: Unlike a blocks and scripts in a workspace, you must use a return statement to return a value.  Scripts do not return the value of the last expression unless you write the work return before it.
  4.  
  5.     As an example, consider the following script for the message discount:
  6.  
  7.         $ on amount.
  8.         $ percent.
  9.         percent := 0.
  10.         if (amount >= 10.00) then [ percent := 0.025 ].
  11.         if (amount >= 25.00) then [ percent := 0.05 ].
  12.         if (amount >= 100.00) then [ percent := 0.075 ].
  13.         return amount * percent.
  14.  
  15.     (Add the property discount to cash-register with this as its script, we‚Äôll need it later). 
  16.  
  17.     The last line of this script has to have the word return.  If it did not, then this script, when executed due to the message discount sent to cash-register, would not return any value at all.
  18.